﻿using NRules.Fluent.Dsl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace Himp.TaskScheduling.Tasks
{
    /// <summary>
    /// 手工取样任务
    /// </summary>
    public class ManualSamplingTaskService : TaskSchedulingAppService, IManualSamplingTaskService
    {
        private IRepository<SampleTestTask, long> _sampleTestTaskRepository;

        public ManualSamplingTaskService(IRepository<SampleTestTask, long> sampleTestTaskRepository)
        {
            _sampleTestTaskRepository = sampleTestTaskRepository;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<SampleTestTaskDto> PostAsync(ManualSamplingTaskCreateDto input)
        {
            SampleTestTask sampleTestTask = new SampleTestTask(input.SampleCode
                   , input.TestCode
                   , input.BottomCode
                   , input.Sampletype
                   , 2
                   , input.TestItems
                   , 1);

            sampleTestTask = await _sampleTestTaskRepository.InsertAsync(sampleTestTask);
            var itemDto = ObjectMapper.Map<SampleTestTask, SampleTestTaskDto>(sampleTestTask);

            return itemDto;
        }
    }
}
